package hibernate_advanced_apply.object_relevance_mapping.many_to_one.config;

import hibernate_advanced_apply.object_relevance_mapping.many_to_one.Teacher;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import java.util.Set;

/**
 * @author Administrator
 * @create 2019-01-04 18:53
 * @desc 双向多对一关联
 **/
public class Test2 {

    public static void main(String args []){

        Configuration config=new Configuration();

        config.configure("hibernate_advanced_apply/" +
                "object_relevance_mapping/many_to_one/config/student_config/mapping.xml");

        SessionFactory factory=config.buildSessionFactory();

        Session session=factory.openSession();

        Transaction tion=session.beginTransaction();

        Teacher teacher=session.get(Teacher.class,3);

        System.out.println(teacher.getName());

    }

}
